package LeetCode;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}19:51
 */
public class interview58 {
    public static void main(String[] args) {
        int[] arr = {2,7,11,15};
    }

    public int[] twoSum(int[] nums, int target) {
        int sum = 0;
        int left = 0;
        int right = nums.length - 1;
        while (left <= right){
            sum = nums[left] + nums[right];
            if (sum > target){
                right--;
            }else if (sum < target){
                left++;
            }else {
                return new int[]{nums[left], nums[right]};
            }
        }
        return new int[]{nums[left], nums[right]};
    }
}
